package cn.com.shbs.Controller;

import cn.com.shbs.Dao.StoreInfoDao.StoreInfoDao;
import cn.com.shbs.model.EmployeeInformation;
import cn.com.shbs.model.LoginUser;
import cn.com.shbs.model.Store;
import net.sf.json.JSONObject;
import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("API/")
public class StoreInfoController {

    @Autowired
    StoreInfoDao storeInfoDao;
    static Logger logger = LoggerFactory.getLogger(StoreInfoController.class);

    @RequestMapping("/querystoreinfo")
    public Object querystoreinfo(HttpServletRequest request, String store_code){
        String message="error";
        JSONObject result=new JSONObject();
        try{
            List<Store> store = storeInfoDao.querystoreinfo(store_code);
            List<EmployeeInformation> employeeInformation = storeInfoDao.queryEmployeeInformationInfo(store_code);
            result.put("store",store);
            result.put("employeeInformation",employeeInformation);
            message = "scuess";
        }catch (Exception e){
            logger.error("StoreInfoController.querystoreinfo()",e);
            e.printStackTrace();
        }
        result.put("message",message);
        return result.toString();
    }



}
